package com.example.xiaosuan.beepdemo;

        import android.support.v7.app.AppCompatActivity;
        import android.os.Bundle;
        import android.view.View;
        import android.widget.Button;

        import com.cbtServiceAndroidSDK.BeepService;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    private Button start;
    private Button stop;
    private Button add;
    private Button sub;
    int i = 100;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //蜂鸣器初始化
        BeepService._init();
        init();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button_kai://点击开始时
                BeepService.PWMPlay(i);
                break;
            case R.id.button_ting://点击结束时
                BeepService.PWMStop();
                break;

            case R.id.button_kuai://点击增加频率时
                i+=10;
                BeepService.PWMPlay(i);
                break;

            case R.id.button_man://点击减小频率时
                i-=10;
                BeepService.PWMPlay(i);
                break;
        }
    }
    private void init(){

        //引入控件
        start = (Button) findViewById(R.id.button_kai);
        stop = (Button) findViewById(R.id.button_ting);
        add = (Button) findViewById(R.id.button_kuai);
        sub = (Button) findViewById(R.id.button_man);

        //注册监听
        start.setOnClickListener(this);
        stop.setOnClickListener(this);
        add.setOnClickListener(this);
        sub.setOnClickListener(this);

    }
}

